﻿(function ($) {
    $.getUrlParam = function (name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]); return null;
    }
})(jQuery);
$.ajaxSetup({
    statusCode: { 999: function (data) { window.location.href = unescape(data.statusText); } }
});
/*
对话框
*/
var messageBox = {};
messageBox.H5Dialog = function (msg) {
    var dd = dialog();
    dd.content("<font size='5'>" + msg + "</font>");
    dd.show();
    setTimeout(function () {
        dd.close().remove();
    }, 2000);
}
messageBox.Confirm = function (msg, okFn) {
    var d = dialog({
        title: '提示',
        content: "<font size='5'>" + msg + "</font>",
        okValue: '确定',
        ok: function () {
            if (okFn) {
                okFn();
            }
            return true;
        },
        cancelValue: '取消',
        cancel: function () { }
    });
    d.show()
}
/*
提示信息并在3秒后跳转到URL
 */
messageBox.H5DialogSkip = function (msg, url) {
    var dd = dialog();
    dd.content("<font size='5'>" + msg + "</font>");
    dd.show();
    setTimeout(function () {
        dd.close().remove();
        window.location.href = url;
    }, 3000);
}

/*
是否微信浏览器打开
 */
function isWeiXin() {
    var ua = window.navigator.userAgent.toLowerCase();
    if (ua.match(/MicroMessenger/i) == "micromessenger") {
        return true;
    } else {
        return false;
    }
}